package com.hualan.sfzy.controller.mind;
import com.hualan.sfzy.entity.mind.TestResult;
import com.hualan.sfzy.service.mind.TestResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("testResult")
public class TestResultController {
    @Autowired
    private TestResultService testResultService;

    @PostMapping
    public int insert(@RequestBody TestResult testResult) {
        return testResultService.add(testResult);
    }

    @PutMapping
    public int update(@RequestBody TestResult testResult) {
        return testResultService.edit(testResult);
    }

    @DeleteMapping("/{id}")
    public int delete(@RequestParam Integer id) {
        return testResultService.remove(id);
    }

    @DeleteMapping()
    public int deleteBatch(@RequestParam Integer[] ids) {
        return testResultService.removeBatch(ids);
    }

    @GetMapping
    public List<TestResult> select(@RequestBody TestResult testResult) {
        return testResultService.find();
    }

    @GetMapping("/{id}")
    public TestResult selectById(@RequestParam Integer id) {
        return testResultService.findById(id);
    }

    @GetMapping("/page")
    public Map<String, Object> findByPage(@RequestParam(defaultValue = "1") Integer pageNum,
                                          @RequestParam(defaultValue = "10") Integer pageSize,
                                          TestResult testResult) {
        return testResultService.findByPage(pageNum, pageSize, testResult);
    }
}